﻿
Public Class frmInicio
    Inherits frmMasterIndex

    Protected Overloads Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            txtRUTCliente.Attributes.Add("onkeypress", "return isNumber(event)")
            txtRUTCliente.Attributes.Add("onkeydown", "return isNumber(event)")
            txtDVRUTCliente.Attributes.Add("onkeydown", "return isAlphaNumber(event);")
            txtDVRUTCliente.Attributes.Add("onkeypress", "return isAlphaNumber(event);")
            txtDVRUTCliente.Attributes.Add("style", "text-transform: uppercase")
        End If
    End Sub

    Protected Sub btnBuscar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBuscar.Click
        If txtRUTCliente.Text.Trim = "" And txtDVRUTCliente.Text.Trim = "" Then
            MsgInformativo("Ingrese RUT.-")
        Else
            ' - Validar RUT
            If ValidaRut(txtRUTCliente.Text.Trim & "-" & txtDVRUTCliente.Text.Trim) Then
                ConsultaDatosCliente(txtRUTCliente.Text)

                If Not RUT Is Nothing Then
                    RUTCliente = txtRUTCliente.Text & "-" & txtDVRUTCliente.Text.ToUpper
                    IrA("frmListadoSeguros.aspx")
                Else
                    MsgInformativo("Cliente Inexistente")
                End If
            Else
                MsgInformativo("RUT No válido")
            End If
        End If
    End Sub

    Protected Sub ConsultaDatosCliente(ByVal RUT As String)
        Dim MiCLT As SRM.CLT0 = New SRM.CLT0("U062")

        ' - Consulta SCS por RUT y obtención de los datos personales (principales)
        If (MiCLT.ObtenerDatosCliente(RUT)) Then
            Me.RUT = RUT
            NombreCliente = MiCLT.Nombre
            ColorCliente = MiCLT.Color
            Email = ""
        End If
    End Sub
End Class